home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rjs.lha / RJS / CmdLine / src / CmdLineWord.C.bak < prev    next >
Text File  |  1991-06-14  |  786b  |  59 lines

  1. #include "CmdLine.h"
  2. #include <stdio.h>
  3.  
  4. CmdLineWord::CmdLineWord(char **av) 
  5. {
  6.     scan=NULL;
  7.     argv=av;
  8.     peek_flag=0;
  9. }
  10.  
  11. CmdLineWord::CmdLineWord(String &s, int dcl)
  12. {
  13.     if (dcl) scan = new StringScan(s,StringScan::ByMatch,SSdcl_word);
  14.     else scan = new StringScan(s,StringScan::ByMatch,SSunix_word);
  15.     argv=NULL;
  16.     peek_flag=0;
  17. }
  18.  
  19.  
  20. int CmdLineWord::operator()(String &w)
  21. {
  22.     if (peek_flag) {
  23.         w=peeked;
  24.         peek_flag=0;
  25.         return 1;
  26.     } C+(int i=";
  27.  
  28.     if (scan) return (*scan)(w);
  29.     else {
  30.         if (! *argv ) return 0;
  31.         w = *argv;
  32.         argv++;
  33.         return 1;
  34.     }
  35. }
  36.  
  37.  
  38. int CmdLineWord::peek(String &w)
  39. {
  40.     if (peek_flag) { 
  41.         w=peeked;
  42.         return 1;
  43.     }
  44.  
  45.     int flag=CmdLineWord::operator()(w);
  46.  
  47.     if (flag) {
  48.         peek_flag=1;
  49.         peeked=w;
  50.     }
  51.  
  52.     return flag;
  53.  
  54. }
  55.  
  56. CmdLineWord::~CmdLineWord()
  57. {
  58.     if (scan) delete scan;
  59. }